Skip to content

Conversation

@devshgraphicsprogramming
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming commented Nov 3, 2025

@keptsecret after you merge master again, you'll probably have the UI mess up and show changed from the merge commit, so close and reopen again

TODO

  • 7 unresolved conversations from RWMC #218, check if done

Comment on lines 7 to 30
template<typename RNG>
struct Uniform1D
{
using rng_type = RNG;
using return_type = uint32_t;

static Uniform1D<RNG> construct(uint32_t2 seed)
{
Uniform1D<RNG> retval;
retval.rng = rng_type::construct(seed);
return retval;
}

return_type operator()()
{
return rng();
}

rng_type rng;
};

template<typename RNG>
struct Uniform3D
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would make sense to just template it on dimensions count

Comment on lines 226 to 220
pathtracer.randGen = randgen_type::create(scramblebuf[coords].rg); // TODO concept this create
pathtracer.randGen = randgen_type::construct(scramblebuf[coords].rg); // TODO concept this create
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we call our pseudo constructors create not construct

Comment on lines +1 to +36
#ifndef _NBL_HLSL_EXT_ACCUMULATOR_INCLUDED_
#define _NBL_HLSL_EXT_ACCUMULATOR_INCLUDED_

#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>

namespace Accumulator
{

template<typename OutputTypeVec NBL_PRIMARY_REQUIRES(concepts::FloatingPointVector<OutputTypeVec>)
struct DefaultAccumulator
{
using input_sample_type = OutputTypeVec;
using output_storage_type = OutputTypeVec;
using this_t = DefaultAccumulator<OutputTypeVec>;
using scalar_type = typename vector_traits<OutputTypeVec>::scalar_type;

static this_t create()
{
this_t retval;
retval.accumulation = promote<OutputTypeVec, scalar_type>(0.0f);

return retval;
}

void addSample(uint32_t sampleCount, input_sample_type _sample)
{
scalar_type rcpSampleSize = 1.0 / (sampleCount);
accumulation += (_sample - accumulation) * rcpSampleSize;
}

output_storage_type accumulation;
};

}

#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to move to Nabla, somewhere in the path_tracing namespace

Comment on lines +10 to +15
namespace nbl
{
namespace hlsl
{
namespace path_tracing
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no namespace for the example

Comment on lines +1 to +19
#ifndef _NBL_HLSL_PATHTRACING_CONCEPTS_INCLUDED_
#define _NBL_HLSL_PATHTRACING_CONCEPTS_INCLUDED_

#include <nbl/builtin/hlsl/concepts.hlsl>

namespace nbl
{
namespace hlsl
{
namespace path_tracing
{
namespace concepts
{

#define NBL_CONCEPT_NAME RandGenerator
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (rand, T)
NBL_CONCEPT_BEGIN(1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole header needs get moved to Nabla

Comment on lines +14 to +17
#else
nbl::hlsl::float32_t4x4 invMVP;
nbl::hlsl::float32_t3x4 generalPurposeLightMatrix;
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you not just use this version for both langs ?

Comment on lines +7 to +9
#ifndef __HLSL_VERSION
#include "matrix4SIMD.h"
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats this for ?

Comment on lines +1 to +2
#ifndef _NBL_HLSL_PATHTRACER_RENDER_RWMC_COMMON_INCLUDED_
#define _NBL_HLSL_PATHTRACER_RENDER_RWMC_COMMON_INCLUDED_
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong header guard, this is example's source

Comment on lines +1 to +2
#ifndef _NBL_HLSL_PATHTRACER_RENDER_COMMON_INCLUDED_
#define _NBL_HLSL_PATHTRACER_RENDER_COMMON_INCLUDED_
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong header guard, this is example's source

Comment on lines +1 to +7
#ifndef _NBL_HLSL_PATHTRACER_RWMC_GLOBAL_SETTINGS_COMMON_INCLUDED_
#define _NBL_HLSL_PATHTRACER_RWMC_GLOBAL_SETTINGS_COMMON_INCLUDED_
#include "nbl/builtin/hlsl/cpp_compat.hlsl"

NBL_CONSTEXPR uint32_t CascadeCount = 6u;

#endif
Copy link
Member Author

@devshgraphicsprogramming devshgraphicsprogramming Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda silly having one header just for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kick it into the main common file

Comment on lines +52 to +54
Shape<scalar_type, PST_SPHERE> light_spheres[1];
Shape<scalar_type, PST_TRIANGLE> light_triangles[1];
Shape<scalar_type, PST_RECTANGLE> light_rectangles[1];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't need unused members if you have getters

if (ImGui::IsKeyPressed(ImGuiKey_S) && params.allowedOp & ImGuizmo::OPERATION::SCALE) // for triangle/rectangle
mCurrentGizmoOperation = ImGuizmo::SCALE_X | ImGuizmo::SCALE_Y;

#if 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats this if 0 about?

Comment on lines +5 to +7
#ifndef __HLSL_VERSION
#include "matrix4SIMD.h"
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the include, not needed

struct RenderRWMCPushConstants
{
RenderPushConstants renderPushConstants;
nbl::hlsl::rwmc::SplattingParameters splattingParameters;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the splatting params shoul have never been compressed in Nabla, they should have been compressed here, and a getter/setter method here too

Comment on lines +4 to +6
#ifdef PERSISTENT_WORKGROUPS
#include "nbl/builtin/hlsl/math/morton.hlsl"
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no needed


float32_t3 color = resolve(accessor, int16_t2(coords.x, coords.y));

//float32_t3 color = rwmc::reweight<rwmc::ResolveAccessorAdaptor<float> >(pc.resolveParameters, cascade, coords);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

Comment on lines +1 to +2
#ifndef _NBL_HLSL_PATHTRACER_RESOLVE_COMMON_INCLUDED_
#define _NBL_HLSL_PATHTRACER_RESOLVE_COMMON_INCLUDED_
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong header guard, this is userspace code


struct ResolvePushConstants
{
uint32_t sampleCount;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variable

Comment on lines +1684 to +1686
RenderRWMCPushConstants rwmcPushConstants;
RenderPushConstants pc;
ResolvePushConstants resolvePushConstants;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you rebuild them every frame from imgui stuff + camera etc?

Maybe lets not store them around as global state and have them transient

Comment on lines +1619 to +1624
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTGLSLPipelines;
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTHLSLPipelines;
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTGLSLPersistentWGPipelines;
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTHLSLPersistentWGPipelines;
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTHLSLPipelinesRWMC;
std::array<smart_refctd_ptr<IGPUComputePipeline>, E_LIGHT_GEOMETRY::ELG_COUNT> m_PTHLSLPersistentWGPipelinesRWMC;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete GLSL code now

Comment on lines +1560 to +1587
void updatePathtracerPushConstants()
{
// disregard surface/swapchain transformation for now
const auto viewProjectionMatrix = m_camera.getConcatenatedMatrix();
// TODO: rewrite the `Camera` class so it uses hlsl::float32_t4x4 instead of core::matrix4SIMD
core::matrix4SIMD invMVP;
viewProjectionMatrix.getInverseTransform(invMVP);
if (useRWMC)
{
memcpy(&rwmcPushConstants.renderPushConstants.invMVP, invMVP.pointer(), sizeof(rwmcPushConstants.renderPushConstants.invMVP));
rwmcPushConstants.renderPushConstants.generalPurposeLightMatrix = hlsl::float32_t3x4(transpose(m_lightModelMatrix));
rwmcPushConstants.renderPushConstants.depth = depth;
rwmcPushConstants.renderPushConstants.sampleCount = resolvePushConstants.sampleCount = spp;
rwmcPushConstants.renderPushConstants.pSampleSequence = m_sequenceBuffer->getDeviceAddress();
//rwmcPushConstants.splattingParameters.log2Start = std::log2(rwmcStart);
//rwmcPushConstants.splattingParameters.log2Base = std::log2(rwmcBase);
float32_t2 packLogs = float32_t2(std::log2(rwmcStart), std::log2(rwmcBase));
rwmcPushConstants.splattingParameters.packedLog2 = hlsl::packHalf2x16(packLogs);
}
else
{
memcpy(&pc.invMVP, invMVP.pointer(), sizeof(pc.invMVP));
pc.generalPurposeLightMatrix = hlsl::float32_t3x4(transpose(m_lightModelMatrix));
pc.sampleCount = spp;
pc.depth = depth;
pc.pSampleSequence = m_sequenceBuffer->getDeviceAddress();
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can move into a lambda somwhere in workLoopBody

Comment on lines +1678 to +1681
float rwmcMinReliableLuma;
float rwmcKappa;
float rwmcStart;
float rwmcBase;
Copy link
Member Author

@devshgraphicsprogramming devshgraphicsprogramming Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gather them up, make nicer create methods for splatting and resolve params

see #218 (comment)

@devshgraphicsprogramming devshgraphicsprogramming mentioned this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants